<form method="post" id="frm" name="form">
<table width="735" height="70" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC" bordercolordark="#FFFFFF">
	  <tr>
      	<td style="border-top:1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left:1px solid #CCCCCC"><div align="left" style="color:#0B55C4; font-family:Tahoma; font-size: 16px; font-weight:bold; padding-left:20px">KIỂU ĐAN</div></td>
      	<td style="border-top:1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; height:65px; width:55px">
		<input type="button" value='' onClick="document.form.action='/sitemanager/?m=mdkd&b=mdkd-insert'; document.form.submit();" style="background:url(/images/bt_them.jpg); width:55px; height:65px;">
		</td>		
		<td style="border-top:1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-right:1px solid #CCCCCC; height:65px; width:55px">
		<input type="button" value='' onClick="document.form.action='/sitemanager/?m=mdkd&b=mdkd-xl-del';document.form.submit();" style="background:url(/images/bt_xoa.jpg); width:55px; height:65px;">       
        </td>
      </tr>
    </table>
    
<table width="735" border="0" cellspacing="0" cellpadding="0">  
  <tr height="30" bgcolor="#FFCC99">
    <td align="center" width="50" style="border-left:1px solid #333;border-right:1px solid #333">Chọn</td>
    <td align="center" width="395" style="border-right:1px solid #333"><strong>Mã kiểu đan</strong></td>
    <td align="center" width="110" style="border-right:1px solid #333"><strong>Hình</strong></td>
    <td align="center" width="100" style="border-right:1px solid #333"><strong>Sửa</strong></td>
    <td align="center" width="100"><strong>Xóa</strong></td>    
  </tr>  
<?php
//		echo "$tp";
        $kq=mysql_query("select count(*) from kieudan"); 
        $r=mysql_fetch_array($kq);
        $numrow=$r[0];		
        //số record cho 1 trang
        $pagesize=21;
        //Tính tổng số trang
        $pagecount=ceil($numrow/$pagesize);			
        //Xác định số trang cho mỗi lần hiển thị
        $segsize=5;
        //Thiết lập trang hiện hành
        if(!isset($_GET["page"]))
			 $curpage=1;
        else	
        	 $curpage=$_GET["page"];
        if($curpage<1)
			 $curpage=1;
        if($curpage>$pagecount) $curpage=$pagecount;
        //Xác định số phân đoạn của trang
        $numseg=($pagecount % $segsize==0)?($pagecount/$segsize):(int)($pagecount/$segsize+1);
        //Xác định phân đoạn hiện hành của trang
        $curseg=($curpage % $segsize==0)?($curpage/$segsize):(int)($curpage/$segsize+1);   
		$k=($curpage-1)*$pagesize;
		
	//******************************** Nội Dung *********************************//
		$sql3="select * from kieudan";
//	echo "$sql3";
		$kq3=mysql_query($sql3);
		if(!$kq3)
			echo "";
		else{
		while($r3=mysql_fetch_array($kq3))
		{
			$idkieu=$r3["id_kieu"];$tenkieu=$r3["tenkieu"];$hinh=$r3["hinh"];
  ?>
  <tr>
  <td width="50" align="center" style="border-left:1px solid #333;border-bottom:1px solid #333; border-right:1px solid #333">
  <input type="checkbox" name="chon[]" value="<?php echo $idkieu; ?>"/></td>  
    <td width="395" align="center" style="border-bottom:1px solid #333; border-right:1px solid #333"><b><?php echo "$tenkieu"; ?></b></td>
    <td width="110" height="110" align="center" style="border-bottom:1px solid #333; border-right:1px solid #333"><img src="/sanpham/small/<?php echo "$hinh"; ?>" width="100" height="100" /></td>
    <td width="100" align="center" style="border-bottom:1px solid #333; border-right:1px solid #333"><a href="?m=mdkd&b=mdkd-update&idkieu=<?php echo "$idkieu"; ?>">Sửa</a></td>
    <td width="100" align="center" style="border-bottom:1px solid #333; border-right:1px solid #333"><a href="?m=mdkd&b=kd-del&idkieu=<?php echo "$idkieu"; ?>" onclick="return check()">Xóa</a>
    </td>
  </tr>
 <?php	 
		}
		}
 ?>
  <tr>
	<td colspan="6" class="ketthuc">
 <?php 	
    if($numrow==0)
		echo "Lỗi SQL!!";
	else{  	
    if($curseg>1)
        echo "<a href='?m=mdkd&b=kd-list&page=".(($curseg-1)*$segsize)."'><b>Previous</b></a> &nbsp;";
        $n=$curseg*$segsize<=$pagecount?$curseg*$segsize:$pagecount;
        for($i=($curseg-1)*$segsize+1;$i<=$n;$i++)
		{
			if($curpage==$i)
				echo "<a href='?m=mdkd&b=kd-list&page=".$i."'><font color='#FF0000'>[".$i."]</font></a> &nbsp;";
			else
				echo "<a href='?m=mdkd&b=kd-list&page=".$i."'><font color='#FFF'>[".$i."]</font></a> &nbsp;";
		}
        if($curseg<$numseg)
		echo "<a href='?m=mdkd&b=kd-list&page=".(($curseg*$segsize)+1)."'><b>Next</b></a> &nbsp;";		
	}	
?>
    </td>
  </tr> 
</table> 
</form>